package com.alpesressources.comexpert;

import java.io.IOException;
import java.util.HashMap;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;

import com.alpesressources.comexpert.bo.request.VoidRequest;
import com.alpesressources.comexpert.bo.response.ErrorResponse;
import com.alpesressources.comexpert.bo.response.Response;
import com.alpesressources.comexpert.bo.response.ServletVersionResponse;
import com.alpesressources.comexpert.bo.response.ErrorResponse.EnumErrorCode;
import com.alpesressources.comexpert.bo.IObject;
import com.alpesressources.comexpert.util.MyJsonSerializer;

public class ServletVersion extends AAction {

	@Override
	public void processGet(ServletConfig config,
			HashMap<String, Object> queryString, HttpServletResponse response)
			throws ServletException, IOException {
	}

	@Override
	public void processPost(ServletConfig config,
			HashMap<String, Object> queryString, IObject postRequest,
			HttpServletResponse response) throws ServletException, IOException {

		Response r = new Response();
		ErrorResponse errorResponse = new ErrorResponse();
		ServletVersionResponse srv = new ServletVersionResponse();

		errorResponse.setErrorCode(EnumErrorCode.NO_ERROR);
		r.setErrorResponse(errorResponse);

		r.getData().add(srv);

		MyJsonSerializer myJsonSerializer = new MyJsonSerializer();

		response.getOutputStream().write(
				myJsonSerializer.serialize(r).getBytes());
	}

	@Override
	public Class<?> getObjectClass() {
		return VoidRequest.class;
	}

}
